Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor: MaxOneRow operator should keep its promise #7375

Merged
merged 4 commits into from
Aug 14, 2018

Conversation

zz-jason
Copy link
Member

@zz-jason zz-jason commented Aug 13, 2018

What problem does this PR solve?

When the child of MaxOneRow operator returns a chunk with only one row, we should check whether the child has more result by calling the child.Next again. In the before, this validation was not employed.

Before this PR, when we set tidb_max_chunk_size to 1, the behavior is wrong:

TiDB(localhost:4000) > set @@tidb_max_chunk_size=1;
Query OK, 0 rows affected (0.00 sec)

TiDB(localhost:4000) > select (select t1.a from t1 where t1.a > t2.a) as a from t2;
+------+
| a    |
+------+
|    1 |
+------+
1 row in set (0.00 sec)

TiDB(localhost:4000) > set @@tidb_max_chunk_size=1024;
Query OK, 0 rows affected (0.00 sec)

TiDB(localhost:4000) > select (select t1.a from t1 where t1.a > t2.a) as a from t2;
ERROR 1105 (HY000): subquery returns more than 1 row

What is changed and how it works?

In this PR, when the first Chunk returned from the child, if the number of records is not equal to 1, we return an error about "subquery returns more than 1 row", Otherwise we call e.children[0].Next again to check whether there are more records existed in the child operator.

Check List

Tests

  • Integration test

Code changes

  • Has exported function/method change

Related changes

  • Need to cherry-pick to the release branch

@zz-jason zz-jason added status/WIP type/bugfix This PR fixes a bug. sig/execution SIG execution labels Aug 13, 2018
Copy link
Contributor

@lysu lysu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@lysu lysu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REST LGTM

@zz-jason
Copy link
Member Author

/run-all-tests

@zz-jason
Copy link
Member Author

@XuHuaiyu @lysu @winoros PTAL

Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zz-jason zz-jason merged commit 9667eca into pingcap:master Aug 14, 2018
@zz-jason zz-jason deleted the dev/fix-max-one-row branch August 14, 2018 04:44
}

childChunk := e.children[0].newChunk()
err = e.children[0].Next(ctx, childChunk)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to check this error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants